package com.example.springevent.listener;

import com.example.springevent.event.GenericEvent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

/**
 * 通用事件监听器 - 处理不同类型的泛型事件
 */
@Slf4j
@Component
public class GenericEventListener {
    
    @EventListener
    public void handleGenericEvent(GenericEvent<?> event) {
        log.info("收到通用事件: 类型 = {}, 数据 = {}", 
                event.getEventType(), 
                event.getData());
    }
    
    @EventListener(condition = "#event.eventType == 'IMPORTANT'")
    public void handleImportantEvent(GenericEvent<?> event) {
        log.info("收到重要事件: 数据 = {}", event.getData());
        // 处理重要事件的特殊逻辑
    }
}